/* GUI CONVERTED from recrtr.p (converter v1.75) Sat Aug 12 23:05:16 2000 */
/* recrtr.p   - REPETITIVE USED TO CREATE TR_HIST RECORDS                     */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/*V8:ConvertMode=Maintenance                                                  */
/*V8:RunMode=Character,Windows */
/* REVISION: 7.3                     CREATED: 11/22/95   BY: JYM *G1DL*       */
/* REVISION: 8.5                   LAST EDIT: 02/21/96   BY: tjs *J0D3*       */
/* REVISION: 8.6E     LAST MODIFIED: 05/09/98   BY: *L00Y* Jeff Wootton       */
/* REVISION: 9.0      LAST MODIFIED: 04/16/99   BY: *J2DG* Reetu Kapoor       */
/* REVISION: 9.1      LAST MODIFIED: 10/01/99   BY: *N014* Jeff Wootton       */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */


/*J2DG*/ /* REPLACED FIND STATEMENTS WITH FOR FIRST STATEMENTS        */
/*J2DG*/ /* FOR ORACLE PERFORMANCE.                                   */

      {mfdeclre.i}

      define input parameter wo_recno as recid no-undo.
      define input parameter gl_amt like glt_amt no-undo.
      define input parameter price like glt_amt no-undo.
      define input parameter qty_chg as decimal no-undo.
      define input parameter msgref like tr_msg no-undo.

      define variable eff_date like tr_effdate initial today no-undo.
      define variable ref like glt_ref no-undo.
          define variable gl_tmp_amt as decimal no-undo.

/*J2DG** BEGIN DELETE **
 *        find first gl_ctrl no-lock.
 *    find wo_mstr where recid(wo_mstr) = wo_recno no-lock.
 *    find pt_mstr where pt_part = wo_part no-lock.
 *    find pl_mstr where pl_prod_line = pt_prod_line no-lock.
 *    find pld_det where pld_prodline = pt_prod_line
 *      and pld_site = wo_site and pld_loc = "" no-lock no-error.
 *J2DG** END DELETE **/

/*J2DG*/ for first gl_ctrl
/*J2DG*/    fields (gl_rnd_mthd) no-lock:
/*J2DG*/ end. /* FOR FIRST GL_CTRL */

/*J2DG*/ for first wo_mstr
/*J2DG*/    fields (wo_nbr wo_part wo_site)
/*J2DG*/    where recid(wo_mstr) = wo_recno no-lock:
/*J2DG*/ end. /* FOR FIRST WO_MSTR */

/*J2DG*/ for first pt_mstr
/*J2DG*/    fields (pt_abc pt_avg_int pt_cyc_int pt_part pt_prod_line
/*J2DG*/            pt_rctpo_active pt_rctpo_status pt_rctwo_active
/*J2DG*/            pt_rctwo_status pt_shelflife pt_um)
/*J2DG*/    where pt_part = wo_part no-lock:
/*J2DG*/ end. /* FOR FIRST PT_MSTR */

/*J2DG*/ for first pl_mstr
/*J2DG*/    fields (pl_dscr_acct
/*N014*/            pl_dscr_sub
/*J2DG*/            pl_dscr_cc pl_inv_acct
/*N014*/            pl_inv_sub
/*J2DG*/            pl_inv_cc pl_prod_line)
/*J2DG*/     where pl_prod_line = pt_prod_line no-lock:
/*J2DG*/ end. /* FOR FIRST PL_MSTR */

/*J2DG*/ for first pld_det
/*J2DG*/    fields (pld_dscracct
/*N014*/            pld_dscr_sub
/*J2DG*/            pld_dscr_cc pld_inv_acct
/*N014*/            pld_inv_sub
/*J2DG*/            pld_inv_cc
/*J2DG*/            pld_loc pld_prodline pld_site)
/*J2DG*/    where pld_prodline = pt_prod_line
/*J2DG*/      and pld_site     = wo_site
/*J2DG*/      and pld_loc      = "" no-lock:
/*J2DG*/ end. /* FOR FIRST PLD_DET */

      if not available pld_det then do:
/*J2DG** find pld_det where pld_prodline = pt_prod_line       */
/*J2DG**  and pld_site = "" and pld_loc = "" no-lock no-error.*/
/*J2DG*/  for first pld_det
/*J2DG*/    fields (pld_dscracct
/*N014*/            pld_dscr_sub
/*J2DG*/            pld_dscr_cc pld_inv_acct
/*N014*/            pld_inv_sub
/*J2DG*/            pld_inv_cc
/*J2DG*/            pld_loc pld_prodline pld_site)
/*J2DG*/    where pld_prodline = pt_prod_line
/*J2DG*/      and pld_site     = ""
/*J2DG*/      and pld_loc      = "" no-lock:
/*J2DG*/ end. /* FOR FIRST PLD_DET */
      end.

             /* UPDATE TRANSACTION HISTORY RECORD */
/*L00Y*/     /* ADDED SECOND EXCHANGE RATE, TYPE, SEQUENCE */
/*N014*/     /* ADDED CRSUB AND DRSUB BELOW */
             {ictrans.i
            &addrid=""""
            &bdnstd=0
            &cracct="
               if available pld_det then pld_dscracct
               else pl_dscr_acct"
            &crsub="
               if available pld_det then pld_dscr_sub
               else pl_dscr_sub"
            &crcc="
               if available pld_det then pld_dscr_cc
               else pl_dscr_cc"
            &crproj=""""
            &curr=""""
            &dracct="
               if available pld_det then pld_inv_acct
               else pl_inv_acct"
            &drsub="
               if available pld_det then pld_inv_sub
               else pl_inv_sub"
            &drcc="
               if available pld_det then pld_inv_cc
               else pl_inv_cc"
            &drproj=""""
            &effdate=today
            &exrate=0
            &exrate2=0
            &exratetype=""""
            &exruseq=0
            &glamt=gl_amt
            &lbrstd=0
            &line=0
            &location=""""
            &lotnumber=""""
            &lotref=""""
            &lotserial=""""
            &mtlstd=0
            &ordernbr=wo_nbr
            &ovhstd=0
            &part=wo_part
            &perfdate=?
            &price=price
            &quantityreq=qty_chg
            &quantityshort=0
            &quantity=0
            &revision=""""
            &rmks=""""
            &shiptype=""M""
            &site=wo_site
            &slspsn1=""""
            &slspsn2=""""
            &sojob=""""
            &substd=0
            &transtype=""CST-ADJ""
            &msg=msgref
            &ref_site=tr_site
             }

             trgl_type = "RCT-AVG".
